#pragma once

//#include <as/interface.h>
//#include "IScriptDevice.h"

#include "Widget.hpp"
#include "LineEdit.hpp"




/**
 * The shell class implements some sort of console, ie. a basic input & output
 * system to interface between the engine and the user.
 */
class ENGINE_UI_API Console : public Widget /*, public as_interface<Console>*/
{
public:

	typedef boost::signal<void(QString)>   command_t;

private:

	//IScriptDevicePtr   m_scriptDevice;

	bool               m_enabled;

	LineEditPtr        m_lineEdit;
	TextPtr            m_text;

	command_t          m_command;

public:

	Console(Widget* parent, Widgets::Type finalType = Widgets::Console);

	/**
	 * Destroys this Console Widget.
	 */
	virtual ~Console();



	/**
	 * Print a message on the console output.
	 */
	void print(QString msg);

	/**
	 * Print a message on the console output.
	 */
	void print(const std::string& line);
	void print(int nbr);
	void print(float nbr);
	void print(double nbr);


	/**
	 * En- or disable the console.
	 */
	void setEnabled(bool enabled);



	//
	// Signal connectors
	//

	boostext::connector<command_t>   command;

protected:

	/**
	 * Get the type of this widget.
	 */
	virtual Widgets::Type type() const;

	/**
	* Updates the widget, based on the current state.
	* All widgets will be updated, no matter what their current state is.
	*/
	virtual void update(NestedState& state);

private:

	//void registerInterface(asIScriptEngine* engine);
};
///////////////////////////////////////////////////////////////////////////////////////////////

DEFINE_LOOSE_PTR(Console);
